<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="referrer" content="never">
    <title>样式操作</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        ul {
            list-style: none;
        }

        .box {
            height: 200px;
        }
    </style>
</head>
<body>
    <div class="box" style="width: 200px"></div>

    <script src="../lib/jquery/jquery.min.js"></script>
    <script type="text/javascript">
        /*
            $ele.css("styleName")  获取样式，带单位的字符串
            $ele.css(styleName, styleValue)  设置样式
            $ele.css({   设置多个样式
                styleName: styleValue,
                styleName: styleValue,
                styleName: styleValue
                ...
            })
        */

        var $box = $(".box");

        console.log("width", $box.css("width"));
        console.log("height", $box.css("height"));

        $box.css("background-color", "#f00");

        $box.css({
            position: "absolute",
            top: "50px", // 可以带单位，也可以不带
            left: 50
        })
    </script>
</body>
</html>